package org.example.threadlocaltest.demos.eneity.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.threadlocaltest.demos.eneity.domain.MyStudent;
import org.example.threadlocaltest.demos.eneity.mapper.MyStudentMapper;
import org.example.threadlocaltest.demos.eneity.service.MyStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author huyingliang
* @description 针对表【my_student(学生表)】的数据库操作Service实现
* @createDate 2024-06-21 14:03:44
*/
@Service
public class MyStudentServiceImpl extends ServiceImpl<MyStudentMapper, MyStudent>
    implements MyStudentService {

    @Autowired
    private MyStudentMapper myStudentMapper;

    @Override
    public List<MyStudent> findAll() {
        return myStudentMapper.selectBatchIds(List.of(1, 2, 3));
    }

    @Override
    public Page<MyStudent> findByPage(Page<MyStudent> myStudentPage) {
        return page(myStudentPage);
    }

    @Override
    public void saveLog(MyStudent myStudent) {
        //休眠3秒
        try {
            Thread.sleep(3000);
            myStudentMapper.insert(myStudent);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}




